const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/db');
const { User } = require('./User');
const AIRole = require('./AIRole');

const Interaction = sequelize.define('Interaction', {
  user_id: {
    type: DataTypes.INTEGER,
    allowNull: false,
    references: {
      model: User,
      key: 'id'
    }
  },
  ai_role_id: {
    type: DataTypes.INTEGER,
    allowNull: false,
    references: {
      model: AIRole,
      key: 'id'
    }
  },
  input: {
    type: DataTypes.TEXT,
    allowNull: false
  },
  response: {
    type: DataTypes.TEXT,
    allowNull: false
  },
  type: {
    type: DataTypes.STRING(255),
    defaultValue: 'text'
  },
  created_at: {
    type: DataTypes.DATE,
    defaultValue: DataTypes.NOW
  }
}, {
  timestamps: false
});

module.exports = Interaction;